<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@include file="view/link.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>模板页面</title>

    <style type="text/css">
        #span_page {
            color: blue;
        }


    </style>
</head>
<body>

<span id="span_page">
    <a href="${pageContext.request.contextPath}/title/query?pageNum=1">>最新话题(点我)</a>
</span>
<%--分页数据--%>
<c:forEach var="title" items="${sessionScope.titlePage.list}">
    <div>
        <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <%--超链接点击展示文章信息和留言信息--%>
            <a href="/title/showMessage?tid=${title.tid}">${title.tname}</a>
        </h2>
        <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <%--超链接点击展示作者信息--%>
        作者：
        <a href="${pageContext.request.contextPath}/user/show?uid=${title.user.uid}">
                ${title.user.uname}
        </a>&nbsp;&nbsp;
                时间${title.tcreateTime}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <%--如果是登录用户的文章就不显示关注了 或者没有登录--%>
            <c:if test="${sessionScope.loginUser==null||sessionScope.loginUser.uid==title.user.uid}">

            </c:if>
            <%--如果不是登录用户的文章就像是关注--%>
            <c:if test="${sessionScope.loginUser.uid!=title.user.uid}">
                <a href="${pageContext.request.contextPath}/title/guanzhu?tid=${title.tid}&&pageNum=${sessionScope.titlePage.pageNum}">关注</a>：${title.tguanZhu}
            </c:if>
             &nbsp;&nbsp;
            <%--如果是当前用户则可以删除--%>
            <c:if test="${not empty sessionScope.loginUser}">
                <c:if test="${title.user.uname == sessionScope.loginUser.uname}">
                    <a href="#">删除</a>&nbsp;&nbsp;
                    <a href="#">编辑</a>
                </c:if>
            </c:if>
        </span>
            <%--截取字符串--%>
        <p>&nbsp;&nbsp;${fn:substring(title.tcontent,0 ,20)}.</p>
    </div>
</c:forEach>
<%--分页连接--%>
<c:if test="${titlePage.pageNum <=1}">

</c:if>
<c:if test="${titlePage.pageNum >1}">
    <a href="${pageContext.request.contextPath}/title/paging?pageNum=${titlePage.pageNum-1}">前一页</a>
</c:if>

<c:forEach begin="${titlePage.start}" var="i" end="${titlePage.end}" step="1">
    <c:if test="${titlePage.pageNum==i}">
        &nbsp;&nbsp; <a href="${pageContext.request.contextPath}/title/paging?pageNum=${i}" style="color: red">${i}</a>&nbsp;&nbsp;
    </c:if>
    <c:if test="${titlePage.pageNum!=i}">
        &nbsp;&nbsp;<a href="${pageContext.request.contextPath}/title/paging?pageNum=${i}">${i}</a>&nbsp;&nbsp
    </c:if>

</c:forEach>
<c:if test="${titlePage.pageNum >= titlePage.totalRecord}">

</c:if>
<c:if test="${titlePage.pageNum < titlePage.totalRecord}">
    <a href="${pageContext.request.contextPath}/title/paging?pageNum=${titlePage.pageNum+1}">后一页</a>
</c:if>

</body>

</html>